<template>
  <div class="member-home">
    <!--  概览-->
    <MemberHomeOverview/>
    <!--  我的收藏-->
    <MemberHomePanel :title="'我的收藏'">
      <template v-if="collectGoods">
        <GoodsItem v-for="item in collectGoods" :key="item.id" :goods="item"/>
      </template>
    </MemberHomePanel>
    <!--  我的足迹-->
    <MemberHomePanel :title="'我的足迹'">
      <template v-if="historyGoods">
        <GoodsItem v-for="item in historyGoods" :key="item.id" :goods="item"/>
      </template>
    </MemberHomePanel>
    <!--  猜你喜欢-->
    <GoodsRelevant/>
  </div>
</template>
<script>
import MemberHomeOverview from '@/views/member/home/components/home-overview'
import MemberHomePanel from '@/views/member/home/components/home-panel'
import GoodsRelevant from '@/views/goods/components/goods-relevant'
import GoodsItem from '@/views/category/components/goods-item'
import { findBrowseHistory, findCollect } from '@/api/member'
import { ref } from 'vue'

export default {
  name: 'MemberHome',
  components: {
    GoodsItem,
    GoodsRelevant,
    MemberHomePanel,
    MemberHomeOverview
  },
  setup () {
    // 模拟数据
    const goods = {
      id: '1',
      name: '自煮火锅不排队 麦饭石不粘鸳鸯火锅',
      picture: 'https://yanxuan-item.nosdn.127.net/fcdcb840a0f5dd754bb8fd2157579012.jpg',
      desc: '清汤鲜香 红汤劲爽',
      price: '159.00'
    }
    // 模拟接口：我的收藏
    const collectGoods = ref([])
    findCollect({
      page: 1,
      pageSize: 4
    }).then(data => {
      collectGoods.value = data.result.items
    })

    // 我的足迹
    const historyGoods = ref([])
    findBrowseHistory({
      page: 1,
      pageSize: 4
    }).then(data => {
      historyGoods.value = data.result.items
    })
    return {
      goods,
      collectGoods,
      historyGoods
    }
  }
}
</script>
<style scoped lang="less">
:deep(.xtx-carousel) .carousel-btn.prev {
  left: 5px;
}

:deep(.xtx-carousel) .carousel-btn.next {
  right: 5px;
}
</style>
